package com.jingtao.rabbitmq.consumer;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName:
 * @Description:
 * @Author: zengfanzhen
 * @Date: 2024/4/8 21:27:50
 */
@Component
public class DirectExchangeConsumer {

    // 监听 direct_queue 队列的消息
    @RabbitListener(queues = "direct_queue")
    public void receiveMessage(String message) {
        System.out.println("从 direct_queue 接收到消息：" + message);
        // 在此处处理接收到的消息逻辑
    }

    // 消费消息时发生异常的处理方法
    @RabbitListener(queues = "direct_queue")
    public void handleException(Exception e) {
        System.out.println("消费消息发生异常：" + e.getMessage());
        // 可以在这里记录日志或者进行其他处理
    }
}

